package com.zkkj.demo.config;

import com.zkkj.demo.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * author : cyc
 * Date : 2019/11/25
 * 拦截器配置类
 */
@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
    public InterceptorConfig() {

    }

    @Bean
    public TokenInterceptor securityInterceptor() {
        return new TokenInterceptor();
    }

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(this.securityInterceptor()).addPathPatterns(new String[]{"/**"}).excludePathPatterns(
                new String[]{
                        "/swagger**",
                        "/v2/**",
                        "/images/**",
                        "/",
                        "/**/*.css",
                        "/**/*.js",
                        "/**/*.png",
                        "/**/*.jpg",
                        "/**/*.jpeg",
                        "/login/login"
                });
    }
}